from django.db import models


# 发送记录
class SentContents(models.Model):
    status_choise = (
        (0, '成功'),
        (1, '失败'),
        (2, '未指定'),
    )
    name = models.CharField(max_length=200, null=True, verbose_name='批次')
    username = models.CharField(max_length=80, null=True, verbose_name='姓名')
    useremail = models.EmailField(null=True,  verbose_name='用户邮箱')
    userphone = models.EmailField(null=True, verbose_name='用户手机号')
    # 适配企业微信工资条，将工资信息保存在这里
    contents = models.TextField(null=True, verbose_name="工资信息")
    time = models.DateTimeField(auto_now_add=True, verbose_name='发送时间')
    pay_month = models.DateField(default="2021-01-01", verbose_name='工资条所属月份')
    status = models.IntegerField(choices=status_choise, default=2, verbose_name='发送状态')
    log = models.CharField(max_length=200, verbose_name='发送日志')
    confirm = models.CharField(max_length=200, default='0', verbose_name='确认状态')
    send_type = models.CharField(max_length=200, verbose_name="发送方式", default="邮件")
    total_money = models.DecimalField(decimal_places=2, max_digits=10, verbose_name="实发工资", default=0)
    mark_id = models.CharField(max_length=64, verbose_name="批次标记ID", null=True)

    class Meta:
        verbose_name = '发送记录'
        verbose_name_plural = verbose_name

    def __unicode__(self):
        return self.name


class BasicInfo(models.Model):
    name_colom = models.IntegerField(default=11, verbose_name='姓名所在列')
    phone_colom = models.IntegerField(default=11, verbose_name='手机号码所在列')
    title_start = models.IntegerField(default=2, verbose_name='标题开始行')
    title_end = models.IntegerField(default=3, verbose_name='标题结束行')
    contact = models.CharField(max_length=100, default="薪酬专员：hr@company.com", verbose_name='人事联系人')
    company_name = models.CharField(max_length=200, default="广东省测试科技有限公司", verbose_name="公司名称")
    total_money_colom = models.IntegerField(default=44, verbose_name='实发薪资所在列')
    # 企业微信联系人
    wechat_admin = models.CharField(max_length=20, verbose_name="微信工资条联系人", default="刘先生")

    class Meta:
        verbose_name = '基础信息'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.contact


class SentIndex(models.Model):
    name = models.CharField(max_length=200, verbose_name='批次主题')
    total = models.IntegerField(verbose_name='合计数据和')
    valid_total = models.IntegerField(default=0, verbose_name="有效数据行")
    ignore_total = models.IntegerField(default=0, verbose_name="忽略的数据行")
    time = models.DateTimeField(auto_now_add=True, verbose_name='发送时间')
    mark_id = models.CharField(max_length=64, verbose_name="批次标记ID", null=True)

    class Meta:
        verbose_name = '发送统计'
        verbose_name_plural = verbose_name

    def __unicode__(self):
        return self.total



